package com.yanqu.road.server.cmd.translate;

import com.yanqu.road.pb.worldmessage.WorldMessageProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.logic.thread.translate.ExTranslateLanguageTask;
import com.yanqu.road.server.logic.thread.translate.MicrosoftTranslateLanguageTask;
import com.yanqu.road.server.manger.sdk.TranslateLanguageMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @Author wpj
 * @Date 2021/4/15
 */
@Cmd(code = GameProtocol.S_TRANSLATE_LANGUAGE, desc = "翻译")
public class TranslateLanguageCmd extends AbstractCommand {

    String content;
    String language;
    long msgIndex;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        WorldMessageProto.TranslationReqMsg msg = WorldMessageProto.TranslationReqMsg.parseFrom(packet.getBytes());
        content = msg.getContent();
        language = msg.getTargetLanguage();
        msgIndex = msg.getMsgIndex();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
//        TranslateLanguageMgr.addTranslateLanguageTask(new TranslateLanguageTask(player, content, language, msgIndex));
//        TranslateLanguageMgr.addMicrosoftTranslateLanguageTask(new MicrosoftTranslateLanguageTask(player, content, language, msgIndex));
        TranslateLanguageMgr.addTranslateTask(new ExTranslateLanguageTask(player, content, language, msgIndex));
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
